<template>
  <div class="login-container flx-center">
    <div class="login-box" v-if="isMobile">
      <SwitchDark class="dark" />
      <div class="login-left">
        <img class="login-left-img" src="@/assets/images/login_left.png" alt="login" />
      </div>
      <div class="login-form">
        <div class="login-logo">
          <img
            class="login-icon"
            :src="configData.Icon"
            :style="{ width: configData.IconWidth, height: configData.IconHeight }"
            alt="logo"
          />
          <div class="logo-text-container">
            <h2 class="logo-text" :style="{ fontSize: configData.systematicNameFontSize }">
              {{ configData.systematicName }}
            </h2>
            <h3 class="logo-text-small" :style="{ fontSize: configData.systematicNameSmallFontSize }">
              {{ configData.systematicNameSmall }}
            </h3>
          </div>
        </div>
        <LoginForm />
      </div>
    </div>
    <div v-else class="mobile-login-box">
      <div>
        <MobileLogin></MobileLogin>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts" name="login">
import { ref, onMounted } from "vue";
import axios from "axios";
import LoginForm from "./components/LoginForm.vue";
import MobileLogin from "@/views/mobile/login/index.vue";
import SwitchDark from "@/components/SwitchDark/index.vue";

// 配置数据
const configData = ref({
  systematicName: "数据管理测试系统",
  systematicNameFontSize: "18px",
  systematicNameSmall: "数据管理",
  systematicNameSmallFontSize: "14px",
  Icon: "/assets/Images/logo.png",
  IconWidth: "16px",
  IconHeight: "16px",
  hideRouter: [],
  title: "数据测试平台"
});

// 是否是移动端
const isMobile = ref(false);
// 判断是移动端还是pc端
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
  isMobile.value = false;
} else {
  isMobile.value = true;
}

onMounted(() => {
  axios.get("/config.json").then(res => {
    configData.value = res.data;
  });
});
</script>

<style scoped lang="scss">
@import "./index.scss";
</style>
